#pragma once
#include <assert.h>
#include <iostream>
using namespace std;
namespace bit
{
	class string
	{
	public:
		friend istream& operator>>(istream& in,string& s);
		friend ostream& operator<<(ostream& out, const string& s);
		friend void swap(string& x, string& y);
		typedef char* iterator;
		typedef const char* const_iterator;
		string(const char* s = "");
		string(const string& s);
		string& operator=(const string& s);
		~string();

		//void swap(string& s);
		const char* c_str();
		iterator begin();
		iterator end();
		const_iterator begin()const;
		const_iterator end()const;
		//string& operator=(const char* s);
		size_t size();
		size_t capacity();
		size_t size()const;
		size_t capacity()const;


		char& operator[](size_t pos);
		const char& operator[](size_t pos)const;
		void reserve(size_t n);
		void push_back(char ch);

		//void append(const char* s);
		void clear();
		bool empty()const;
		const char front()const;
		const char back()const;

		string& operator+=(const char* s);
		string& operator+=(const char c);

		string& append(const char* s);
		string assign(const char* s);

		string& insert(size_t pos, const char* s);
		string& insert(size_t pos, const char ch);
		string& erase(size_t pos = 0, size_t len = npos);
		//void swap(const string& s);
		void pop_back();

		size_t find(const char c, size_t pos = 0);
		string substr(size_t pos = 0, size_t len = npos);

		bool operator==(string& s);
		bool operator!=(string& s);
		bool operator>(string& s);
		bool operator>=(string& s);
		bool operator<(string& s);
		bool operator<=(string& s);
	private:
		char* _str;
		size_t _size;
		size_t _capacity;
		static const size_t npos = -1;
	};
	istream& operator>>(istream& in,string& s);
	ostream& operator<<(ostream& out,const string& s);
	void swap(string& x, string& y);
}
